package wy2;

import java.util.Arrays;
import java.util.Scanner;

public class Main3 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int s1 = sc.nextInt();
        int[] array = new int[s1];
        for (int i = 0; i < array.length; i++) {
            array[i] = sc.nextInt();
        }
        int sum = 0;
        Arrays.sort(args);
        int i = 0;
        while (array[i] == 1) {
            i++;
        }
        if (array[0] == 1) {
            sum = (s1 - i - 1) * (s1 - i) / 2;
        }
        for (; i < s1; i++) {
            int count1 = 1;
            int tempSum = 0;
            while (i + 1 < s1 && array[i] == array[i + 1]) {
                i++;
                count1++;
            }
            for (int j = i + 1; j < s1; j++) {
                int gcd = gcd(array[i], array[j]);
                if (gcd == 1) {
                    tempSum = tempSum + (s1 - j - 1)*count1;
                    if(count1>1){
                        tempSum+=count1*(count1+1)/2;
                    }
                    continue;
                }
                for (int k = j + 1; k < s1; k++) {
                    if (gcd(gcd, array[k]) == 1) {
                        tempSum=tempSum+count1;
                    }
                }

            }
            sum += tempSum ;
        }
        System.out.println(sum);
    }


    private static int gcd(int a, int b) {
        while (a != b) {
            if (a > b) {
                a = a - b;
            }
            if (a < b) {
                b = b - a;
            }
        }
        return a;
    }
}
/*
8
1 2 3 4 5 6 7 8

 */